package pATT.DataSetsGenerator.dataSetsGenerator.generator.visual;

import java.awt.Dimension;
import java.awt.Font;
import java.awt.GraphicsConfiguration;
import java.awt.HeadlessException;
import java.awt.Toolkit;
import java.util.Enumeration;
import java.util.Vector;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.table.TableColumn;
import javax.swing.table.TableModel;

import pATT.DataSetsGenerator.dataSetsGenerator.attribute.implement.Attribute;
import pATT.DataSetsGenerator.dataSetsGenerator.attribute.implement.IntegerAttribute;
import pATT.DataSetsGenerator.dataSetsGenerator.attribute.implement.NominalAttribute;
import pATT.DataSetsGenerator.dataSetsGenerator.attribute.implement.RealAttribute;
import pATT.DataSetsGenerator.dataSetsGenerator.core.implement.Relation;
import pATT.DataSetsGenerator.dataSetsGenerator.core.implement.RelationManager;
import pATT.DataSetsGenerator.dataSetsGenerator.core.implement.Support;
import pATT.DataSetsGenerator.dataSetsGenerator.core.visual.RelationGenerator.ToDoListModel;
import pATT.DataSetsGenerator.dataSetsGenerator.data.implement.DataManager;
import pATT.DataSetsGenerator.dataSetsGenerator.data.implement.IData;
import pATT.DataSetsGenerator.dataSetsGenerator.data.implement.Data;
import pATT.help.visual.HelpFrame;
import pATT.logger.Message;

@SuppressWarnings("serial")
public class RandomFrame extends JFrame {
	
	protected String nameGenerator = "Random Generator";
	private JPanel jContentPane = null;
	private JLabel jLabel = null;
	private JLabel jLabel1 = null;
	protected JPanel jPanel = null;
	private JLabel jLabel2 = null;
	protected JComboBox jComboBox = null;
	private JPanel jIntegerPanel1 = null;
	private JLabel jLabel3 = null;
	private JLabel jLabel4 = null;
	private JTextField jTextField = null;
	private JLabel jLabel5 = null;
	private JTextField jTextField1 = null;
	private JButton jButton = null;
	private JPanel jNominalPanel1 = null;
	private JLabel jLabel6 = null;
	private JTextField jTextField2 = null;
	private JButton jButton1 = null;
	private JButton jButton2 = null;
	private JPanel jContentPane1 = null;
	private JScrollPane jScrollPane = null;
	private JTable jTable = null;
	private int contTable=0;
	private JButton jButton3 = null;
	private JPanel jRealPanel1 = null;
	private JTextField jTextField3 = null;
	private JLabel jLabel7 = null;
	private JLabel jLabel8 = null;
	private JLabel jLabel9 = null;
	private JTextField jTextField4 = null;
	private JButton jButton4 = null;
	private JTextField jTextField5 = null;
	private JLabel jLabel10 = null;
	protected DataManager manager = null;
	private JButton jHelpButton5 = null;
	
	public RandomFrame() throws HeadlessException {
		super();
		// TODO Auto-generated constructor stub
		initialize();
	}
	
	public RandomFrame(GraphicsConfiguration arg0) {
		super(arg0);
		// TODO Auto-generated constructor stub
		initialize();
	}
	
	public RandomFrame(String arg0) throws HeadlessException {
		super(arg0);
		// TODO Auto-generated constructor stub
		initialize();
	}
	
	public RandomFrame(String arg0, GraphicsConfiguration arg1) {
		super(arg0, arg1);
		// TODO Auto-generated constructor stub
		initialize();
	}
	
	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		Relation relation = RelationManager.instance.getCurrentRelation();
		Vector<IData> vec = new Vector<IData>();
		vec = generateData(relation.getAtributes());
		manager = new DataManager(relation,vec,nameGenerator);
		
		this.setSize(600, 328);
		this.setBackground(null);
		this.setResizable(false);
		Dimension pantalla = Toolkit.getDefaultToolkit().getScreenSize();
		Dimension freim = this.getSize();
		if (pantalla.width < freim.width){
			freim.width = pantalla.width;
		}
		if (pantalla.height < freim.height) {
			freim.height = pantalla.height;
		}
		this.setLocation((pantalla.width-freim.width)/2,(pantalla.height-freim.height)/2);

		this.setContentPane(getJContentPane1());
		this.setTitle("Relation Generator Rule - "+nameGenerator);
		jLabel1.setText(relation.getName());
	}
	
	private Vector<IData> generateData(Vector<Attribute> attributes){
		Vector<IData> vector = new Vector<IData>();
		for (int i = 0; i < attributes.size(); i++) {
			vector.addElement(new Data(attributes.elementAt(i)));
		}
		return vector;
	}
	
	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jLabel1 = new JLabel();
			jLabel1.setBounds(new java.awt.Rectangle(80,0,149,20));
			jLabel1.setFont(new java.awt.Font("Microsoft Sans Serif", java.awt.Font.PLAIN, 13));
			jLabel1.setForeground(java.awt.Color.blue);
			jLabel1.setBackground(java.awt.SystemColor.control);
			jLabel1.setText("<Relation>");
			jLabel = new JLabel();
			jLabel.setBounds(new java.awt.Rectangle(1,0,72,20));
			jLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
			jLabel.setFont(new java.awt.Font("Microsoft Sans Serif", java.awt.Font.PLAIN, 13));
			jLabel.setForeground(java.awt.Color.blue);
			jLabel.setBackground(java.awt.SystemColor.control);
			jLabel.setText("Relation: ");
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.setBounds(new java.awt.Rectangle(9,4,585,290));
			jContentPane.setBackground(java.awt.SystemColor.control);
			jContentPane.add(jLabel, null);
			jContentPane.add(jLabel1, null);
			jContentPane.add(getJPanel(), null);
			jContentPane.add(getJButton1(), null);
			jContentPane.add(getJButton2(), null);
			jContentPane.add(getJScrollPane(), null);
			jContentPane.add(getJHelpButton5(), null);
		}
		return jContentPane;
	}
	
	/**
	 * This method initializes defaultTableModel	
	 * 	
	 * @return javax.swing.table.DefaultTableModel	
	 */
	
	
	/**
	 * This method initializes jPanel	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPanel() {
		if (jPanel == null) {
			jLabel2 = new JLabel();
			jLabel2.setFont(new java.awt.Font("Microsoft Sans Serif", java.awt.Font.PLAIN, 11));
			jLabel2.setLocation(new java.awt.Point(23,10));
			jLabel2.setSize(new java.awt.Dimension(186,20));
			jLabel2.setBackground(java.awt.SystemColor.activeCaptionBorder);
			jLabel2.setText("Specify generation options for attribute");
			jPanel = new JPanel();
			jPanel.setLayout(null);
			jPanel.setBounds(new java.awt.Rectangle(238,32,347,219));
			jPanel.setBackground(java.awt.SystemColor.activeCaptionBorder);
			jPanel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
			jPanel.add(jLabel2, null);
			jPanel.add(getJComboBox(), null);
			jPanel.add(getJIntegerPanel1(), null);
			jPanel.add(getJNominalPanel1(), null);
			//**************
			jPanel.add(getJRealPanel1(), null);
			
		}
		return jPanel;
	}
	
	/**
	 * This method initializes jComboBox	
	 * 	
	 * @return javax.swing.JComboBox	
	 */
	private JComboBox getJComboBox() {
		if (jComboBox == null) {
			jComboBox = new JComboBox();
			jComboBox.setFont(new java.awt.Font("Microsoft Sans Serif", java.awt.Font.PLAIN, 11));
			jComboBox.setSize(new java.awt.Dimension(111,20));
			jComboBox.setLocation(new java.awt.Point(213,10));
			jComboBox.setForeground(java.awt.Color.blue);
			
			//Vector<Attribute> vecAttributes = randomGenerator.getRelation().getAtributes();
			Vector<Attribute> vecAttributes = manager.getRelation().getAtributes();
			for (int i = 0; i < vecAttributes.size(); i++) {
				jComboBox.addItem(vecAttributes.get(i).getName());	
			}
			
			jComboBox.setSelectedIndex(-1);
			jComboBox.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					if(jComboBox != null && jNominalPanel1 != null && jIntegerPanel1 != null && jRealPanel1 != null){
						int pos = jComboBox.getSelectedIndex();
						Attribute attr = manager.getRelation().getAtributes().get(pos);
						if(jComboBox.getSelectedItem().equals(attr.getName()) && attr.getType().equals("Integer")){
							jNominalPanel1.setVisible(false);
							jRealPanel1.setVisible(false);
							jIntegerPanel1.setVisible(true);
							jTextField.setText(String.valueOf((int)((IntegerAttribute)attr).getLimitDown()));
							jTextField1.setText(String.valueOf((int)((IntegerAttribute)attr).getLimitUp()));
						}
						else
							if(jComboBox.getSelectedItem().equals(attr.getName()) && attr.getType().equals("Nominal")){
								jIntegerPanel1.setVisible(false);
								jRealPanel1.setVisible(false);
								jNominalPanel1.setVisible(true);
								jTextField2.setText(String.valueOf(((NominalAttribute)attr).getStringValues()));
							}
							else 
								if(jComboBox.getSelectedItem().equals(attr.getName()) && attr.getType().equals("Real")){
									jIntegerPanel1.setVisible(false);
									jNominalPanel1.setVisible(false);
									jRealPanel1.setVisible(true);
									jTextField3.setText(String.valueOf(((RealAttribute)attr).getLimitDown()));
									jTextField4.setText(String.valueOf(((RealAttribute)attr).getLimitUp()));
									jTextField5.setText(String.valueOf(((RealAttribute)attr).getTransition()));
								}
								else {
									jIntegerPanel1.setVisible(false);
									jNominalPanel1.setVisible(false);
									jRealPanel1.setVisible(false);
									
								}
					}
					
				}
			});
		}
		return jComboBox;
	}
	
	/**
	 * This method initializes jPanel1	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJIntegerPanel1() {
		if (jIntegerPanel1 == null) {
			jLabel5 = new JLabel();
			jLabel5.setBounds(new java.awt.Rectangle(137,40,47,23));
			jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
			jLabel5.setFont(new java.awt.Font("Microsoft Sans Serif", java.awt.Font.PLAIN, 11));
			jLabel5.setText("and");
			jLabel4 = new JLabel();
			jLabel4.setBounds(new java.awt.Rectangle(24,40,53,23));
			jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
			jLabel4.setFont(new java.awt.Font("Microsoft Sans Serif", java.awt.Font.PLAIN, 11));
			jLabel4.setText("between");
			jLabel3 = new JLabel();
			jLabel3.setText("Integer values");
			jLabel3.setSize(new java.awt.Dimension(78,21));
			jLabel3.setLocation(new java.awt.Point(3,7));
			jLabel3.setFont(new java.awt.Font("Microsoft Sans Serif", java.awt.Font.PLAIN, 11));
			jIntegerPanel1 = new JPanel();
			jIntegerPanel1.setLayout(null);
			jIntegerPanel1.setBackground(java.awt.SystemColor.activeCaptionBorder);
			jIntegerPanel1.setEnabled(true);
			jIntegerPanel1.setVisible(false);
			jIntegerPanel1.setLocation(new java.awt.Point(7,51));
			jIntegerPanel1.setSize(new java.awt.Dimension(331,95));
			jIntegerPanel1.add(jLabel3, null);
			jIntegerPanel1.add(jLabel4, null);
			jIntegerPanel1.add(getJTextField(), null);
			jIntegerPanel1.add(jLabel5, null);
			jIntegerPanel1.add(getJTextField1(), null);
			jIntegerPanel1.add(getJButton(), null);
		}
		return jIntegerPanel1;
	}
	
	/**
	 * This method initializes jTextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTextField() {
		if (jTextField == null) {
			jTextField = new JTextField();
			jTextField.setBounds(new java.awt.Rectangle(76,40,62,23));
		}
		return jTextField;
	}
	
	/**
	 * This method initializes jTextField1	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTextField1() {
		if (jTextField1 == null) {
			jTextField1 = new JTextField();
			jTextField1.setLocation(new java.awt.Point(183,40));
			jTextField1.setSize(new java.awt.Dimension(62,23));
		}
		return jTextField1;
	}
	
	/**
	 * This method initializes jButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButton() {
		if (jButton == null) {
			jButton = new JButton();
			jButton.setLocation(new java.awt.Point(255,39));
			jButton.setToolTipText("");
			jButton.setText("Set");
			jButton.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
			jButton.setFont(new java.awt.Font("Microsoft Sans Serif", java.awt.Font.PLAIN, 11));
			jButton.setBackground(java.awt.SystemColor.activeCaptionBorder);
			jButton.setSize(new java.awt.Dimension(60,23));
			jButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					int pos = jComboBox.getSelectedIndex();
					if(isIntegerCorrect()){
						//********busco el atributo y le seteo los nuevos limites
						Data data = (Data)manager.getData(pos);
						int down = Integer.parseInt(jTextField.getText().trim());
						int up = Integer.parseInt(jTextField1.getText().trim());
						((IntegerAttribute)data.getAttribute()).setNewLimits(down,up);
						//*****************
						
						jIntegerPanel1.setVisible(false);
						//jComboBox.setSelectedIndex(-1);
					}
				}
			});
		}
		return jButton;
	}
	
	private boolean isNominalCorrect() {
		boolean valid = true;
		if(jTextField2.getText().trim().equals("") || jTextField2.getText().trim().equals("<complete>")){
			valid = false;
			jTextField2.setText("<complete>");
		}
		if(!Support.isValuesNominalCorrect(jTextField2.getText())){
			valid = false;
			jTextField2.setText("<complete>");
		}
		return valid;
	}
	
	private boolean isRealCorrect() {
		boolean valid = true;
		if(jTextField3.getText().trim().equals("<complete>"))
			valid = false;
		if(jTextField4.getText().trim().equals("<complete>"))
			valid = false;
		if(!Support.isDouble(jTextField5.getText()) || jTextField5.getText().trim().equals("<complete>")){
			valid = false;
			jTextField5.setText("<complete>");
		}
		if(!Support.minusRealThan(jTextField3.getText(),jTextField4.getText())){
			valid = false;
			jTextField3.setText("<complete>");
			jTextField4.setText("<complete>");
		}
		
		return valid;
	}
	private boolean isIntegerCorrect() {
		boolean valid = true;
		if(!Support.isDigit(jTextField.getText())){
			valid = false;
			jTextField.setText("<complete>");
		} 
		if(!Support.isDigit(jTextField1.getText())){
			valid = false;
			jTextField1.setText("<complete>");
		}
		if(!Support.minusIntegerThan(jTextField.getText(),jTextField1.getText())){
			valid = false;
			jTextField.setText("<complete>");
			jTextField1.setText("<complete>");
		}
		
		return valid;	
	}
	
	/**
	 * This method initializes jPanel1	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJNominalPanel1() {
		if (jNominalPanel1 == null) {
			jLabel6 = new JLabel();
			jLabel6.setFont(new java.awt.Font("Microsoft Sans Serif", java.awt.Font.PLAIN, 11));
			jLabel6.setSize(new java.awt.Dimension(78,21));
			jLabel6.setLocation(new java.awt.Point(3,7));
			jLabel6.setText("Nominal values");
			jNominalPanel1 = new JPanel();
			jNominalPanel1.setLayout(null);
			jNominalPanel1.setBackground(java.awt.SystemColor.activeCaptionBorder);
			jNominalPanel1.setVisible(false);
			jNominalPanel1.setSize(new java.awt.Dimension(331,95));
			jNominalPanel1.setLocation(new java.awt.Point(7,51));
			jNominalPanel1.add(jLabel6, null);
			jNominalPanel1.add(getJTextField2(), null);
			jNominalPanel1.add(getJButton3(), null);
		}
		return jNominalPanel1;
	}
	
	/**
	 * This method initializes jTextField2	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTextField2() {
		if (jTextField2 == null) {
			jTextField2 = new JTextField();
			jTextField2.setBounds(new java.awt.Rectangle(25,41,223,22));
		}
		return jTextField2;
	}
	
	/**
	 * This method initializes jPanel1	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	
	/**
	 * This method initializes jCheckBox	
	 * 	
	 * @return javax.swing.JCheckBox	
	 */
	
	
	/**
	 * This method initializes jTextField3	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	
	
	/**
	 * This method initializes jGaussianPanel1	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	
	/**
	 * This method initializes jMuTextField3	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	
	/**
	 * This method initializes jButton1	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButton1() {
		if (jButton1 == null) {
			jButton1 = new JButton();
			jButton1.setText("Generate");
			jButton1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
			jButton1.setSize(new java.awt.Dimension(76,22));
			jButton1.setFont(new java.awt.Font("Microsoft Sans Serif", java.awt.Font.PLAIN, 11));
			jButton1.setBackground(java.awt.SystemColor.control);
			jButton1.setLocation(new java.awt.Point(250,261));
			jButton1.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					
					manager.random();	
					//RelationManager.instance.getCurrentRelation().setMethodRandom("Random");
					dispose();
				}
			});
		}
		return jButton1;
	}
	
	/**
	 * This method initializes jButton2	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButton2() {
		if (jButton2 == null) {
			jButton2 = new JButton();
			jButton2.setBounds(new java.awt.Rectangle(340,261,76,22));
			jButton2.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
			jButton2.setFont(new java.awt.Font("Microsoft Sans Serif", java.awt.Font.PLAIN, 11));
			jButton2.setBackground(java.awt.SystemColor.control);
			jButton2.setText("Cancel");
			jButton2.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					dispose();
				}
			});
		}
		return jButton2;
	}
	
	/**
	 * This method initializes jContentPane1	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJContentPane1() {
		if (jContentPane1 == null) {
			jContentPane1 = new JPanel();
			jContentPane1.setLayout(null);
			jContentPane1.setBackground(java.awt.SystemColor.control);
			jContentPane1.add(getJContentPane(), null);
		}
		return jContentPane1;
	}
	
	/**
	 * This method initializes jScrollPane	
	 * 	
	 * @return javax.swing.JScrollPane	
	 */
	private JScrollPane getJScrollPane() {
		if (jScrollPane == null) {
			jScrollPane = new JScrollPane();
			jScrollPane.setBounds(new java.awt.Rectangle(5,34,225,216));
			jScrollPane.setBackground(java.awt.SystemColor.control);
			jScrollPane.setViewportView(getJTable());
		}
		return jScrollPane;
	}
	
	/**
	 * This method initializes jTable	
	 * 	
	 * @return javax.swing.JTable	
	 */
	private JTable getJTable() {
		if (jTable == null) {
			jTable = new JTable();
			jTable.setSize(new java.awt.Dimension(223,219));
			TableColumn tc1= new TableColumn();
			TableColumn tc2= new TableColumn();
			TableColumn tc3= new TableColumn();
			tc1.setHeaderValue("NAME");
			tc2.setHeaderValue("TYPE");
			tc3.setHeaderValue("NULL");
			jTable.addColumn(tc1);
			jTable.addColumn(tc2);// JVE Generated
			jTable.addColumn(tc3);
			tc1.setModelIndex(0);
			tc2.setModelIndex(1);
			tc3.setModelIndex(2);
			jTable.setAutoCreateColumnsFromModel(false); // JVE Generated
			jTable.setModel(new ToDoListModel());
			jTable.setFont(new java.awt.Font("Microsoft Sans Serif", java.awt.Font.PLAIN, 10));
			loadTable();
			
			
			
		}
		return jTable;
	}
	
	@SuppressWarnings("unchecked")
	public void loadTable(){
		Vector vec=new Vector();
		vec.addAll(RelationManager.instance.getCurrentRelation().getAtributes());
		for (Enumeration e=vec.elements();e.hasMoreElements();){
			Attribute attr=(Attribute) e.nextElement();
			TableModel model = jTable.getModel();
			model.setValueAt(attr.getName(),contTable,0);
			model.setValueAt(attr.getType(),contTable, 1);
			model.setValueAt(String.valueOf(attr.isNull()),contTable, 2);
			contTable++;
		}
		
	}
	
	
	/**
	 * This method initializes jButton3	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButton3() {
		if (jButton3 == null) {
			jButton3 = new JButton();
			jButton3.setLocation(new java.awt.Point(255,39));
			jButton3.setText("Set");
			jButton3.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
			jButton3.setFont(new java.awt.Font("Microsoft Sans Serif", java.awt.Font.PLAIN, 11));
			jButton3.setBackground(java.awt.SystemColor.activeCaptionBorder);
			jButton3.setSize(new java.awt.Dimension(60,23));
			jButton3.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					int pos = jComboBox.getSelectedIndex();
					if (isNominalCorrect()){
						Data data = (Data)manager.getData(pos);
						String values = jTextField2.getText().trim();
						((NominalAttribute)data.getAttribute()).setNewValues(values);
						
						jNominalPanel1.setVisible(false);
						//jComboBox.setSelectedIndex(-1);
					}
					
				}
			});
		}
		return jButton3;
	}
	
	/**
	 * This method initializes jRealPanel1	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJRealPanel1() {
		if (jRealPanel1 == null) {
			jLabel10 = new JLabel();
			jLabel10.setFont(new java.awt.Font("Microsoft Sans Serif", java.awt.Font.PLAIN, 11));
			jLabel10.setLocation(new java.awt.Point(24,70));
			jLabel10.setSize(new java.awt.Dimension(53,23));
			jLabel10.setText("Transition");
			jLabel9 = new JLabel();
			jLabel9.setHorizontalAlignment(SwingConstants.CENTER);
			jLabel9.setText("and");
			jLabel9.setSize(new java.awt.Dimension(47,23));
			jLabel9.setLocation(new java.awt.Point(137,40));
			jLabel9.setFont(new Font("Microsoft Sans Serif", Font.PLAIN, 11));
			jLabel8 = new JLabel();
			jLabel8.setHorizontalAlignment(SwingConstants.CENTER);
			jLabel8.setText("between");
			jLabel8.setSize(new java.awt.Dimension(53,23));
			jLabel8.setLocation(new java.awt.Point(24,40));
			jLabel8.setFont(new Font("Microsoft Sans Serif", Font.PLAIN, 11));
			jLabel7 = new JLabel();
			jLabel7.setText("Real values");
			jLabel7.setSize(new java.awt.Dimension(78,21));
			jLabel7.setFont(new java.awt.Font("Microsoft Sans Serif", java.awt.Font.PLAIN, 11));
			jLabel7.setLocation(new java.awt.Point(3,7));
			jRealPanel1 = new JPanel();
			jRealPanel1.setLayout(null);
			jRealPanel1.setLocation(new java.awt.Point(7,51));
			jRealPanel1.setSize(new java.awt.Dimension(331,95));
			jRealPanel1.setBackground(java.awt.SystemColor.activeCaptionBorder);
			jRealPanel1.setVisible(false);
			jRealPanel1.add(getJTextField3(), null);
			jRealPanel1.add(jLabel7, null);
			jRealPanel1.add(jLabel8, null);
			jRealPanel1.add(jLabel9, null);
			jRealPanel1.add(getJTextField4(), null);
			jRealPanel1.add(getJButton4(), null);
			jRealPanel1.add(getJTextField5(), null);
			jRealPanel1.add(jLabel10, null);
		}
		return jRealPanel1;
	}
	
	/**
	 * This method initializes jTextField3	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTextField3() {
		if (jTextField3 == null) {
			jTextField3 = new JTextField();
			jTextField3.setLocation(new java.awt.Point(76,40));
			jTextField3.setSize(new java.awt.Dimension(62,23));
		}
		return jTextField3;
	}
	
	/**
	 * This method initializes jTextField4	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTextField4() {
		if (jTextField4 == null) {
			jTextField4 = new JTextField();
			jTextField4.setSize(new java.awt.Dimension(62,23));
			jTextField4.setLocation(new java.awt.Point(183,40));
		}
		return jTextField4;
	}
	
	/**
	 * This method initializes jButton4	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButton4() {
		if (jButton4 == null) {
			jButton4 = new JButton();
			jButton4.setFont(new java.awt.Font("Microsoft Sans Serif", java.awt.Font.PLAIN, 11));
			jButton4.setSize(new java.awt.Dimension(60,23));
			jButton4.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
			jButton4.setLocation(new java.awt.Point(255,39));
			jButton4.setBackground(java.awt.SystemColor.activeCaptionBorder);
			jButton4.setText("Set");
			jButton4.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					int pos = jComboBox.getSelectedIndex();
					if(isRealCorrect()){
						Data data = (Data)manager.getData(pos);
						double down = Double.parseDouble(jTextField3.getText().trim());
						double up = Double.parseDouble(jTextField4.getText().trim());
						double trans = Double.parseDouble(jTextField5.getText().trim());
						((RealAttribute)data.getAttribute()).setNewLimits(down,up,trans);
						
						jRealPanel1.setVisible(false);
						//jComboBox.setSelectedIndex(-1);
					}
					
				}
			});
		}
		return jButton4;
	}
	
	/**
	 * This method initializes jTextField5	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTextField5() {
		if (jTextField5 == null) {
			jTextField5 = new JTextField();
			jTextField5.setLocation(new java.awt.Point(82,70));
			jTextField5.setSize(new java.awt.Dimension(53,23));
		}
		return jTextField5;
	}

	/**
	 * This method initializes jHelpButton5	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJHelpButton5() {
		if (jHelpButton5 == null) {
			jHelpButton5 = new JButton();
			jHelpButton5.setText("Help");
			jHelpButton5.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
			jHelpButton5.setSize(new java.awt.Dimension(55,35));
			jHelpButton5.setLocation(new java.awt.Point(527,254));
			jHelpButton5.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					callHelp();
				}
			});
		}
		return jHelpButton5;
	}

	protected void callHelp() {
		new HelpFrame(Message.TITLE_RANDOM,Message.BODY_RANDOM).show();
		
	}
}  //  @jve:decl-index=0:visual-constraint="10,10"
